﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="EstoreInfo.ascx.cs" Inherits="Administrator_AdminControl_EstoreInfo" %>
<%--
<link href="<%= ResolveUrl("~/Styles/TabPanels.css")%>" rel="stylesheet" type="text/css" />--%>
<div class="dasboard">
    <div class="staticTitle">
        Thông tin doanh nghiệp</div>
    <div runat="server" style="float: right; padding: 10px 30px 0 0">
        <asp:ImageButton ID="imgAdd" runat="server" ToolTip="Thêm mới" ImageUrl="~/images/Admin/icon_add.gif"
            OnClick="imgAdd_Click" />Thêm</div>
    <div class="style-padding1">
        <asp:Repeater ID="rptInfo" runat="server" OnItemCommand="rptInfo_ItemCommand">
            <HeaderTemplate>
                <table class="headertable" cellpadding="0">
                    <tr>
                        <th style="width: 5%;">
                            STT
                        </th>
                        <th style="width: 25%">
                            Tên doanh nghiệp
                        </th>
                        <th style="width: 20%">
                            Website
                        </th>
                        <th style="width: 10%">
                            Điểm vòng xoay may mắn
                        </th>
                        <th style="width: 10%">
                            Tổng số điểm
                        </th>
                        <th style="width: 10%">
                            Số lần click
                        </th>
                        <th>
                        </th>
                        <th style="width: 10%">
                        </th>
                    </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <td style="text-align: center;">
                        <%#Container.ItemIndex+1 %>
                        <input type="hidden" value='<%#DataBinder.Eval(Container.DataItem,"EStore_Id") %>' />
                    </td>
                    <td>
                        <%# DataBinder.Eval(Container.DataItem, "EStore_Name")%>
                    </td>
                    <td>
                        <%# DataBinder.Eval(Container.DataItem,"EStore_Website")%>
                    </td>
                    <td style="text-align: center;">
                        <%# DataBinder.Eval(Container.DataItem,"EStore_LuckCyclePoint")%>
                    </td>
                    <td style="text-align: center;">
                        <%# DataBinder.Eval(Container.DataItem,"EStore_TotalPoint")%>
                    </td>
                    <td style="text-align: center;">
                        <%# DataBinder.Eval(Container.DataItem,"EStore_Click")%>
                    </td>
                    <td style="text-align: center;">
                        <asp:ImageButton ID="btnedit" runat="server" ImageUrl="~/images/Admin/icon_edit.gif"
                            CommandName="edit" ToolTip="Sửa" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"EStore_Id") %>' />&nbsp;
                        <asp:ImageButton ID="btnDelete" runat="server" ImageUrl="~/images/Admin/icon_delete.gif.png"
                            CommandName="delete" ToolTip="Xóa" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"EStore_Id") %>'
                            OnClientClick="return confirm('Bạn có chắc muốn xóa không?')" />
                    </td>
                    <td style="text-align: center;">
                        <%--<asp:Button ID="btnUpgradeVip" OnClick="btnUpgradeVip_Click" runat="server" OnClientClick="javascript:openDialog(this.ID);return false;" Text="Nâng cấp VIP" />--%>
                        <input id="btnUpgradeVip" type="button" onclick="javascript:openDialog(this);" value="Nâng cấp VIP" />
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </div>
</div>
<!--End dasboard-->
<asp:Panel ID="pnlDetail" runat="server" Visible="false">
    <div id="dialogDetail" class="dasboard">
        <div class="staticTitle">
            Thông tin chi tiết của doanh nghiệp:
            <asp:Label ID="lblName" runat="server"></asp:Label>
        </div>
        <div class="style-padding1">
            <table id="tbldetail">
                <tr>
                    <td>
                        Tên doanh nghiệp:
                    </td>
                    <td colspan="3">
                        <asp:TextBox ID="txtName" runat="server" Width="100%" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Tên người chủ quản
                    </td>
                    <td>
                        <asp:DropDownList ID="drdUser" runat="server" Width="100%" />
                    </td>
                    <td style="padding-left: 30px">
                        Người đại diện
                    </td>
                    <td>
                        <asp:TextBox ID="txtRepresent" runat="server" Width="100%" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Mã số thuế
                    </td>
                    <td>
                        <asp:TextBox ID="txtTax" runat="server" Width="100%" />
                    </td>
                    <td style="padding-left: 30px">
                        Di động
                    </td>
                    <td>
                        <asp:TextBox ID="txtMobil" runat="server" Width="100%" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Điện thoại bàn
                    </td>
                    <td>
                        <asp:TextBox ID="txtPhone" runat="server" Width="100%" />
                    </td>
                    <td style="padding-left: 30px">
                        Website
                    </td>
                    <td>
                        <asp:TextBox ID="txtWeb" runat="server" Width="100%" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Fax
                    </td>
                    <td>
                        <asp:TextBox ID="txtFax" runat="server" Width="100%" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Địa chỉ
                    </td>
                    <td>
                        <asp:TextBox ID="txtAddress" runat="server" Width="100%" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Tỉnh thành
                    </td>
                    <td>
                        <asp:DropDownList ID="drdCity" runat="server" Width="100%" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Ngành nghề
                    </td>
                    <td>
                        <asp:DropDownList ID="drdJob" runat="server" Width="100%" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Nick Yahoo
                    </td>
                    <td>
                        <asp:TextBox ID="txtYahoo" runat="server" Width="100%" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Nick Skype
                    </td>
                    <td>
                        <asp:TextBox ID="txtSky" runat="server" Width="100%" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Tóm tắt
                    </td>
                    <td>
                        <asp:TextBox ID="txtDes" runat="server" TextMode="MultiLine" Rows="5" Width="100%" />
                    </td>
                </tr>
            </table>
            <asp:Button ID="btnUpdate" runat="server" Text="Cập nhật" OnClick="btnUpdate_Click"
                Visible="false" />
            <asp:Button ID="btnSave" runat="server" Text="Lưu" Visible="false" OnClick="btnSave_Click" />

            <asp:Button ID="btnCancel" runat="server" Text="Thoát" OnClick="btnCancel_Click"
                Visible="true" />
        </div>
    </div>
    <!--End dasboard-->
    <asp:Label ID="lblEstoreID" runat="server" Visible="false"></asp:Label>
</asp:Panel>
<asp:ScriptManager runat="server" ID="rm" EnablePageMethods="true">
</asp:ScriptManager>
<script src="<%= ResolveUrl("~/Scripts/jquery.simplemodal.js")%>" type="text/javascript"></script>
<script type="text/javascript">
    function openDialog(element) {
//      var content = $(element.parentNode.parentNode).find("td:eq(1)").html();
        var id = $(element.parentNode.parentNode).find("td:eq(0)").find("input")[0].value;
        PageMethods.GetEstoreByID(id, GetName_OK);
    }


    //save point VIP for business
    function SaveUpgrade() {
        var estoreID = $("#<%=hddID.ClientID %>").val();
        var packageID = $("#<%=ddrPackage.ClientID %>").val();
        PageMethods.BusinessUpgrade(estoreID, packageID,Upgrade_OK,Upgrade_Fail);   
           
    }

    function GetName_OK(result) {
        if (Date.parse(result.KindToDate) > Date.now() ) {
            if (confirm("Gói doanh nghiệp VIP đang xài vẫn còn hiệu lực. Bạn vẫn muốn nâng cấp?")) {
                $("#<%=txtBusiness.ClientID %>").val(result.Name);
                $("#<%=hddID.ClientID %>").val(result.ID);
                $('#dialogUpgrade').modal();
            }
        }
        else {
            $("#<%=txtBusiness.ClientID %>").val(result.Name);
            $("#<%=hddID.ClientID %>").val(result.ID);
            $('#dialogUpgrade').modal();
        }
        
    }

    function Upgrade_OK(flag) {
        if (flag == true){
            $.modal.close();
            location.reload(true);
            alert("Bạn đã nâng cấp thành công.");
        }
        else
            alert("Hiện tại doanh nghiệp này không đủ điểm để nâng cấp gói VIP này. Bạn hãy chọn gói khác để nâng cấp VIP! ");
    }
    function Upgrade_Fail ()
    {
    }
    

</script>
<div id="dialogUpgrade">
    <div style="text-align: center;">
        Nâng cấp doanh nghiệp VIP</div>
    <div class="style-padding1">
        <table style="width: 70%; line-height: 50px;">
            <tr>
                <td>
                    Doanh nghiệp
                </td>
                <td style="width: 70%">
                    <asp:TextBox ID="txtBusiness" runat="server" Width="100%"  />
                    <asp:HiddenField ID="hddID" runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    Gói DN VIP
                </td>
                <td style="width: 70%">
                    <asp:DropDownList ID="ddrPackage" runat="server" Width="100%" />
                </td>
            </tr>
        </table>
        <div style="text-align: center;">
            <%--<asp:LinkButton ID="lbtSaveUpgrade" runat="server" Text="Lưu" OnClick="lbt_Click"></asp:LinkButton>--%>
            <asp:Button runat="server" ID="btnSaveUpgrade" Text="Luu" OnClientClick="javascript:SaveUpgrade()"/>
        </div>
    </div>
</div>
